/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlutils;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.microedition.io.Connector;
import javax.microedition.io.ContentConnection;
import org.kxml.kdom.Document;
import org.kxml.kdom.Element;
import org.kxml.parser.XmlParser;

/**
 *
 * @author Administrator
 */
public class MapXmlData {

    private ConditionsData conditionsData;
    private UserData userData;
    private RadarData radarData;
    private SatelliteData satelliteData;
    private SlpData slpData;
    private TempData tempData;
    private VisibilityData visibilityData;
    private WindData windData;

    public MapXmlData(String url) throws IOException {
        ContentConnection connection = (ContentConnection) Connector.open(url);
        InputStream in = connection.openDataInputStream();
        InputStreamReader isr = new InputStreamReader(in);
        XmlParser parser = null;
        Document doc = new Document();        
        parser = new XmlParser(isr);

        // Pass the parser to the document.  At this point the
        // entire resource is parsed and now resides in memory.
        doc.parse(parser);
    
        Element root = doc.getRootElement();
        conditionsData = new ConditionsData(root.getElement("CONDITIONS"));
        userData = new UserData(root.getElement("USER"));
        radarData = new RadarData(root.getElement("RADAR"));
        satelliteData = new SatelliteData(root.getElement("SATELLITE"));
        slpData = new SlpData(root.getElement("SLP"));
        tempData = new TempData(root.getElement("TEMP"));
        visibilityData = new VisibilityData(root.getElement("VISIBILITY"));
        windData = new WindData(root.getElement("WIND"));
        System.out.println("");
    }

    public ConditionsData getConditionsData() {
        return conditionsData;
    }

    public RadarData getRadarData() {
        return radarData;
    }

    public SatelliteData getSatelliteData() {
        return satelliteData;
    }

    public SlpData getSlpData() {
        return slpData;
    }

    public TempData getTempData() {
        return tempData;
    }

    public UserData getUserData() {
        return userData;
    }

    public VisibilityData getVisibilityData() {
        return visibilityData;
    }

    public WindData getWindData() {
        return windData;
    }
}
